package cn.jsj.onclock.controller;

import cn.jsj.onclock.interceptor.swich.PassToken;
import cn.jsj.onclock.pojo.AdEnt;
import cn.jsj.onclock.result.Result;
import cn.jsj.onclock.service.AdService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


/**
 * @author 卢斌
 */
@Slf4j
@Controller
@CrossOrigin
@ResponseBody
@RestController
@RequestMapping(value = "/ad")
public class AdController {

    private final AdService adService;

    @Autowired
    public AdController(AdService adService) {
        log.info("日志");
        this.adService = adService;
    }


    /**
     * 随机查询一个广告信息
     */
    @PassToken
    @GetMapping(value = "/ad")
    public Result<AdEnt> getOneAd() {
        AdEnt adEnt = adService.getRandomAd();
        return Result.success(adEnt);
    }

}
